/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package labbd_._projetofinal;

import java.sql.Date;
import java.sql.SQLException;
import oracle.jdbc.OracleCallableStatement;
import oracle.jdbc.OracleConnection;

/**
 *
 * @author bimaoe
 */
public class Pagamento {

	public static void pagaBoleto(OracleConnection in_conn, int in_idcompra,
		String in_banco) throws SQLException{

		String query = "begin pkg_formaPagamento.proc_pagaBoleto (?,?); end;";
		OracleCallableStatement Ocallstmt = (OracleCallableStatement) in_conn.prepareCall(query);
		Ocallstmt.setInt(1, in_idcompra);
		Ocallstmt.setString(2, in_banco);
		try {
			Ocallstmt.execute();
		} catch (SQLException ex) {
			ex.printStackTrace();
			throw ex;
		}
	}

	public static void pagaPayPal (OracleConnection in_conn, int in_idcompra,
		String in_login) throws SQLException {

		String query = "begin pkg_formaPagamento.proc_pagaPayPal (?,?); end;";
		OracleCallableStatement Ocallstmt = (OracleCallableStatement) in_conn.prepareCall(query);
		Ocallstmt.setInt(1, in_idcompra);
		Ocallstmt.setString(2, in_login);
		try {
			Ocallstmt.execute();
		} catch (SQLException ex) {
			ex.printStackTrace();
			throw ex;
		}
	}

	public static void pagaCartao (OracleConnection in_conn, int in_idcompra,
		String in_bandeira, int in_nrocartao, int in_cvc, String in_validade) throws SQLException {
		String query = "begin pkg_formaPagamento.proc_pagaCartao (?,?,?,?,?); end;";
		OracleCallableStatement Ocallstmt = (OracleCallableStatement) in_conn.prepareCall(query);
		Ocallstmt.setInt(1, in_idcompra);
		Ocallstmt.setString(2, in_bandeira);
		Ocallstmt.setInt(3, in_nrocartao);
		Ocallstmt.setInt(4, in_cvc);
		Ocallstmt.setDate(5, Date.valueOf(in_validade+"-01"));
		
		try {
			Ocallstmt.execute();
		} catch (SQLException ex) {
			ex.printStackTrace();
			throw ex;
		}
	}

}
